package StatePattern.example1;

public class Student implements ScoreContext {
    private ScoreState state = LowScoreState.getInstance();
    private final String name;

    public Student(String name) {
        this.name = name;
    }

    @Override
    public void setScore(int score) {
        state.setScore(this, score);
    }

    @Override
    public void changeState(ScoreState state) {
        this.state = state;
    }

    @Override
    public String getStateName() {
        return state.getStateName();
    }

    @Override
    public String toString() {
        return "Student{" +
                "分数状态=" + getStateName() +
                ", 姓名='" + name + '\'' +
                '}';
    }
}
